package com.example.util;

import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;

public class JvmUtil {
    public static final long getModMemory()
    {
        return Runtime.getRuntime().maxMemory();
    }

    /**
     * 获取进程id
     * @return 进程id
     */
    public static final int getProcessID()
    {

        RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
        String jvmInstanceName = runtimeMXBean.getName();
        return Integer.valueOf(jvmInstanceName.split("@")[0]).intValue();
    }

    public static void main(String[] args) {
        System.out.println("getMxMemory() = "+getModMemory()/1024/1024/1024+" G");
    }

    public static boolean isWin(){
        String os = System.getProperty("os.name");
        if(os.toLowerCase().startsWith("win")){
            return true;
        }else{
            return false;
        }
    }
}
